package com.blacktry.mapper;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.blacktry.entity.model.Admin;
import com.blacktry.entity.model.CourseDistribution;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.blacktry.entity.model.Vo.ClassCourseVo;
import com.blacktry.entity.model.Vo.Research;
import com.blacktry.entity.model.vueVO.CourseInfo;
import com.blacktry.entity.model.vueVO.Info;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * Mapper 接口
 * </p>
 *
 * @author blackTry
 * @since 2021-12-05
 */
@Mapper
public interface CourseDistributionMapper extends BaseMapper<CourseDistribution> {

    @Select("select course_distribution.*,course.course_name,admin.`name` ,classroom.`name` as class_name from role,admin,admin_role,course_distribution,course,classroom " +
            "where role.name='ROLE_teacher' and role.id=admin_role.role_id AND admin.id=admin_role.admin_id" +
            " and admin.username=course_distribution.user_id and course_distribution.course_id=course.course_id and classroom.id = course_distribution.classroom_id")
    Page<CourseDistribution> getCourseDistributionTable(CourseDistribution courseDistribution, Page<CourseDistribution> courseDistributionPage);

    Page<CourseDistribution> selectPageByCD(CourseDistribution courseDistribution, Page<CourseDistribution> courseDistributionPage);


    Page<Research> researchWorkGoing(Admin admin, Page<Research> researchPage);

    List<ClassCourseVo> selectClassId2Course();


    //根据教师名字查询所教的科目
    List<String> selectCourseName(String userId);

    //根据教师名字和课程名查询所教的班级
    String selectClassName(String userId,String courseName);

    //根据课程名查看所有班级
    String selectClassNameByCourseName(String courseName);


    //学生查询自己要上的课程
    String[] studentSelectCourseName(String userName);



    // 根据课程id查询可以教这门课的老师及其归属
    List<Info> selectTeacherNameAndAffiliation(String courseId);


    // 根据姓名查询该教师已分配的课程信息
    List<CourseInfo> selectTeacherWork(String userId);



}
